﻿// <com.woyouqiu.Copyright>
// --------------------------------------------------------------
// <copyright>上海有求网络科技有限公司 2015</copyright>
// <Solution>BangChuang</Solution>
// <Project>BangChuang.Core</Project>
// <FileName>UserType.cs</FileName>
// <CreateTime>2017-04-16 20:22</CreateTime>
// <Author>何苗</Author>
// <Email>hemiao@woyouqiu.com</Email>
// <log date="2017-04-16 20:22" version="00001">创建</log>
// --------------------------------------------------------------
// </com.woyouqiu.Copyright>

using System.ComponentModel.DataAnnotations;

namespace Vecen.BangChuang.BangChuang {
    public static class UserType {
        /// <summary>
        /// 内部用户(价格作为成本价)
        /// </summary>
        public const string InnerUser = "InnerUser";

        /// <summary>
        /// 普通客户(价格作为出厂价)
        /// </summary>
        public const string GeneralUser = "GeneralUser";

        /// <summary>
        /// 一级代理(价格作为一级代理价)
        /// </summary>
        public const string FirstAgentUser = "FirstAgentUser";

        /// <summary>
        /// 二级代理(价格作为二级代理价)
        /// </summary>
        public const string SecondAgentUser = "SecondAgentUser";
    }

    public class UserTypeRangeAttribute: ValidationAttribute {
        public override bool IsValid(object value) {
            if(value != null) {
                switch(value.ToString()) {
                    case UserType.InnerUser:
                    case UserType.GeneralUser:
                    case UserType.FirstAgentUser:
                    case UserType.SecondAgentUser: return true;
                    default: return false;
                }
            } else {
                return true;
            }
        }
    }
}